package com.heer.gymnasium.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.heer.gymnasium.R;
import com.heer.gymnasium.util.LoadImageUtil;
import com.heer.model.MyWalletBean;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by rzw2 on 2017/4/5.
 */

public class MyWalletAdapter extends ListAdapter<MyWalletBean> {
    public MyWalletAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder holder;
        if (view != null) {
            holder = (ViewHolder) view.getTag();
        } else {
            view = mInflater.inflate(R.layout.item_my_wallet, parent, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        }

        MyWalletBean item = getItem(position);

        Glide.with(mContext)
                .load(LoadImageUtil.getLoadImageUrl(item.getStadiumpic()))
                .placeholder(R.mipmap.ic_default_avatar)
                .into(holder.imageSite);
        if (!TextUtils.isEmpty(item.getStadiumname()))
            holder.tvSite.setText(item.getStadiumname());
        else
            holder.tvSite.setText("方形运动馆");
        if (!TextUtils.isEmpty(item.getMoney()))
            holder.tvBalance.setText("余额:"+item.getMoney());
        else
            holder.tvBalance.setText("余额:"+"0");
        return view;
    }

    static class ViewHolder {
        @BindView(R.id.image_site)
        ImageView imageSite;
        @BindView(R.id.tv_site)
        TextView tvSite;
        @BindView(R.id.tv_balance)
        TextView tvBalance;
        @BindView(R.id.btn_recharge)
        TextView btnRecharge;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
